const HtmlWebpackPlugin = require('html-webpack-plugin');
const path = require('path');

module.exports = {
    entry: {
        main: path.resolve(__dirname, "..", "src/index.tsx"),
    },
    output: {
        path: path.resolve(__dirname, "..", "dist"),
        filename: "[name].js",
        clean: true,
    },
    module: {
        rules: [
            {
                test: /\.(js|ts|jsx|tsx)$/,
                loader: "babel-loader",
                exclude: [/node_modules/],
                options: {
                    presets: ['@babel/preset-react', '@babel/preset-typescript']
                }
            }
        ]
    },
    plugins: [
        new HtmlWebpackPlugin({
            template: path.resolve(__dirname, '..', 'template.html')
        })
    ],
    resolve: {
        extensions: ['.js', '.ts', '.jsx', '.tsx']
    },
    optimization: {
        splitChunks: {
            chunks: 'all',
        }
    }
}